package Model;

import java.io.Serializable;

import Messaging.Notification;
import Messaging.NotificationManager;

/* 
 * @author Mark de Lira
 */

public class UpgradeablePropertyLevel1 extends UpgradeablePropertyState implements Serializable 
{
	
	private static UpgradeablePropertyLevel1 INSTANCE = null;
	final static long serialVersionUID = 223;
	
	protected UpgradeablePropertyLevel1()
	{
	
	}
	
	public static UpgradeablePropertyState Instance() 
	{
		if (INSTANCE == null) 
		{
			INSTANCE = new UpgradeablePropertyLevel1();
		}
		
		return INSTANCE;
	}

	public void landOn(Player player, PropertySpace property) 
	{
		property.getOwner().collectRent(property.getRentValues()[1], player);
	}
	
	protected void renovate(UpgradeablePropertySpace p) 
	{
		p.changeState(UpgradeablePropertyLevel2.Instance());
		NotificationManager.getInstance().notifyObservers
		(Notification.UPDATE_PROPERTIES, new Player(p.getOwner()));
		
	}
	
	protected void downgrade(UpgradeablePropertySpace p) 
	{
		p.changeState(PropertyOwned.Instance());
		NotificationManager.getInstance().notifyObservers
		(Notification.UPDATE_PROPERTIES, new Player(p.getOwner()));
	}
	
	protected boolean isUpgradeable(UpgradeablePropertySpace p)
	{
		return p.getOwner().monopolyUpgradeValid(p);
	}
	
	protected boolean isDowngradeable(UpgradeablePropertySpace p) 
	{
		return p.getOwner().monopolyDowngradeValid(p);
	}
	
	protected String getNameAndStatus() 
	{
		return " (Level 1)";
	}
	
	public int getLevel()
	{
		return 1;
	}
	
	public String toString()
	{
		return "UpgradeablePropertyLevel1";
	}
}
